home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / info / elisp-14.z / elisp-14
Encoding:
GNU Info File  |  1994-08-02  |  50.2 KB  |  1,202 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This version is newer than the second printed edition of the GNU
  5. Emacs Lisp Reference Manual.  It corresponds to Emacs Version 19.19.
  6.  
  7.    Published by the Free Software Foundation 675 Massachusetts Avenue
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26.    Permission is granted to copy and distribute modified versions of
  27. this manual under the conditions for verbatim copying, provided also
  28. that the section entitled "GNU Emacs General Public License" is included
  29. exactly as in the original, and provided that the entire resulting
  30. derived work is distributed under the terms of a permission notice
  31. identical to this one.
  32.  
  33.    Permission is granted to copy and distribute translations of this
  34. manual into another language, under the above conditions for modified
  35. versions, except that the section entitled "GNU Emacs General Public
  36. License" may be included in a translation approved by the Free Software
  37. Foundation instead of in the original English.
  38.  
  39. 
  40. File: elisp,  Node: Repeat Events,  Next: Motion Events,  Prev: Button-Down Events,  Up: Input Events
  41.  
  42. Repeat Events
  43. -------------
  44.  
  45.    If you press the same mouse button more than once in quick succession
  46. without moving the mouse, Emacs uses special "repeat" mouse events for
  47. the second and subsequent presses.
  48.  
  49.    The most common repeat events are "double-click" events.  Emacs
  50. generates a double-click event when you click a button twice; the event
  51. happens when you release the button (as is normal for all click events).
  52.  
  53.    The event type of a double-click event contains the prefix `double'.
  54. Thus, a double click on the second mouse button with meta held down
  55. comes to the Lisp program as `M-double-mouse-2'.  If a double-click
  56. event has no binding, the binding of the corresponding ordinary click
  57. event is used to execute it.  Thus, you need not pay attention to the
  58. double click feature unless you really want to.
  59.  
  60.    When the user performs a double click, Emacs generates first an
  61. ordinary click event, and then a double-click event.  Therefore, the
  62. command binding of the double click event must be written to assume
  63. that the single-click command has already run.  It must produce the
  64. desired results of a double click, starting from the results of a
  65. single click.
  66.  
  67.    This means that it is most convenient to give double clicks a meaning
  68. that somehow "builds on" the meaning of a single click.  This is what
  69. user interface experts recommend that double clicks should do.
  70.  
  71.    If you click a button, then press it down again and start moving the
  72. mouse with the button held down, then you get a "double-drag" event
  73. when you ultimately release the button.  Its event type contains
  74. `double-drag' instead of just `drag'.  If a double-drag event has no
  75. binding, Emacs looks for an alternate binding as if the event were an
  76. ordinary click.
  77.  
  78.    Before the double-click or double-drag event, Emacs generates a
  79. "double-down" event when the button is pressed down for the second
  80. time.  Its event type contains `double-down' instead of just `down'.
  81. If a double-down event has no binding, Emacs looks for an alternate
  82. binding as if the event were an ordinary button-down event.  If it
  83. finds no binding that way either, the double-down event is ignored.
  84.  
  85.    To summarize, when you click a button and then press it again right
  86. away, Emacs generates a double-down event, followed by either a
  87. double-click or a double-drag.
  88.  
  89.    If you click a button twice and then press it again, all in quick
  90. succession, Emacs generates a "triple-down" event, followed by either a
  91. "triple-click" or a "triple-drag".  The event types of these events
  92. contain `triple' instead of `double'.  If any triple event has no
  93. binding, Emacs uses the binding that it would use for the corresponding
  94. double event.
  95.  
  96.    If you click a button three or more times and then press it again,
  97. the events for the presses beyond the third are all triple events.
  98. Emacs does not have quadruple, quintuple, etc. events as separate event
  99. types.  However, you can look at the event list to find out precisely
  100. how many times the button was pressed.
  101.  
  102.  - Function: event-click-count EVENT
  103.      This function returns the number of consecutive button presses
  104.      that led up to EVENT.  If EVENT is a double-down, double-click or
  105.      double-drag event, the value is 2.  If EVENT is a triple event,
  106.      the value is 3 or greater.  If EVENT is an ordinary mouse event
  107.      (not a repeat event), the value is 1.
  108.  
  109.  - Variable: double-click-time
  110.      To count as double- and triple-clicks, mouse clicks must be at the
  111.      same location as the first click, and the number of milliseconds
  112.      between the first release and the second must be less than the
  113.      value of `double-click-time'.  Setting `double-click-time' to
  114.      `nil' disables multi-click detection entirely.  Setting it to `t'
  115.      removes the time limit; Emacs then detects multi-clicks by
  116.      position only.
  117.  
  118. 
  119. File: elisp,  Node: Motion Events,  Next: Focus Events,  Prev: Repeat Events,  Up: Input Events
  120.  
  121. Motion Events
  122. -------------
  123.  
  124.    Emacs sometimes generates "mouse motion" events to describe motion
  125. of the mouse without any button activity.  Mouse motion events are
  126. represented by lists that look like this:
  127.  
  128.      (mouse-movement
  129.       (WINDOW BUFFER-POS
  130.        (COLUMN . ROW) TIMESTAMP))
  131.  
  132.    The second element of the list describes the current position of the
  133. mouse, just as in a click event (*note Click Events::.).
  134.  
  135.    The special form `track-mouse' enables generation of motion events
  136. within its body.  Outside of `track-mouse' forms, Emacs does not
  137. generate events for mere motion of the mouse, and these events do not
  138. appear.
  139.  
  140.  - Special Form: track-mouse BODY...
  141.      This special form executes BODY, with generation of mouse motion
  142.      events enabled.  Typically BODY would use `read-event' to read the
  143.      motion events and modify the display accordingly.
  144.  
  145.      When the user releases the button, that generates a click event.
  146.      Normally BODY should return when it sees the click event, and
  147.      discard the event.
  148.  
  149. 
  150. File: elisp,  Node: Focus Events,  Next: Event Examples,  Prev: Motion Events,  Up: Input Events
  151.  
  152. Focus Events
  153. ------------
  154.  
  155.    Window systems provide general ways for the user to control which
  156. window gets keyboard input.  This choice of window is called the
  157. "focus".  When the user does something to switch between Emacs frames,
  158. that generates a "focus event".  The normal definition of a focus event,
  159. in the global keymap, is to select a new frame within Emacs, as the user
  160. would expect.  *Note Input Focus::.
  161.  
  162.    Focus events are represented in Lisp as lists that look like this:
  163.  
  164.      (switch-frame NEW-FRAME)
  165.  
  166. where NEW-FRAME is the frame switched to.
  167.  
  168.    In X windows, most window managers are set up so that just moving the
  169. mouse into a window is enough to set the focus there.  Emacs appears to
  170. do this, because it changes the cursor to solid in the new frame.
  171. However, there is no need for the Lisp program to know about the focus
  172. change until some other kind of input arrives.  So Emacs generates the
  173. focus event only when the user actually types a keyboard key or presses
  174. a mouse button in the new frame; just moving the mouse between frames
  175. does not generate a focus event.
  176.  
  177.    A focus event in the middle of a key sequence would garble the
  178. sequence.  So Emacs never generates a focus event in the middle of a key
  179. sequence.  If the user changes focus in the middle of a key
  180. sequence--that is, after a prefix key--then Emacs reorders the events
  181. so that the focus event comes either before or after the multi-event key
  182. sequence, and not within it.
  183.  
  184. 
  185. File: elisp,  Node: Event Examples,  Next: Classifying Events,  Prev: Focus Events,  Up: Input Events
  186.  
  187. Event Examples
  188. --------------
  189.  
  190.    If the user presses and releases the left mouse button over the same
  191. location, that generates a sequence of events like this:
  192.  
  193.      (down-mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864320))
  194.      (mouse-1      (#<window 18 on NEWS> 2613 (0 . 38) -864180))
  195.  
  196.    Or, while holding the control key down, the user might hold down the
  197. second mouse button, and drag the mouse from one line to the next.
  198. That produces two events, as shown here:
  199.  
  200.      (C-down-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219))
  201.      (C-drag-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219)
  202.                      (#<window 18 on NEWS> 3510 (0 . 28) -729648))
  203.  
  204.    Or, while holding down the meta and shift keys, the user might press
  205. the second mouse button on the window's mode line, and then drag the
  206. mouse into another window.  That produces the following pair of events:
  207.  
  208.      (M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844))
  209.      (M-S-drag-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)
  210.                        (#<window 20 on carlton-sanskrit.tex> 161 (33 . 3)
  211.                         -453816))
  212.  
  213. 
  214. File: elisp,  Node: Classifying Events,  Next: Accessing Events,  Prev: Event Examples,  Up: Input Events
  215.  
  216. Classifying Events
  217. ------------------
  218.  
  219.    Every event has an "event type" which classifies the event for key
  220. binding purposes.  For a keyboard event, the event type equals the event
  221. value; thus, the event type for a character is the character, and the
  222. event type for a function key symbol is the symbol itself.  For events
  223. which are lists, the event type is the symbol in the CAR of the list.
  224. Thus, the event type is always a symbol or a character.
  225.  
  226.    Two events of the same type are equivalent where key bindings are
  227. concerned; thus, they always run the same command.  That does not
  228. necessarily mean they do the same things, however, as some commands look
  229. at the whole event to decide what to do.  For example, some commands use
  230. the location of a mouse event to decide what text to act on.
  231.  
  232.    Sometimes broader classifications of events are useful.  For example,
  233. you might want to ask whether an event involved the META key,
  234. regardless of which other key or mouse button was used.
  235.  
  236.    The functions `event-modifiers' and `event-basic-type' are provided
  237. to get such information conveniently.
  238.  
  239.  - Function: event-modifiers EVENT
  240.      This function returns a list of the modifiers that EVENT has.  The
  241.      modifiers are symbols; they include `shift', `control', `meta',
  242.      `alt', `hyper' and `super'.  In addition, the property of a mouse
  243.      event symbol always has one of `click', `drag', and `down' among
  244.      the modifiers.  For example:
  245.  
  246.           (event-modifiers ?a)
  247.                => nil
  248.           (event-modifiers ?\C-a)
  249.                => (control)
  250.           (event-modifiers ?\C-%)
  251.                => (control)
  252.           (event-modifiers ?\C-\S-a)
  253.                => (control shift)
  254.           (event-modifiers 'f5)
  255.                => nil
  256.           (event-modifiers 's-f5)
  257.                => (super)
  258.           (event-modifiers 'M-S-f5)
  259.                => (meta shift)
  260.           (event-modifiers 'mouse-1)
  261.                => (click)
  262.           (event-modifiers 'down-mouse-1)
  263.                => (down)
  264.  
  265.      The modifiers list for a click event explicitly contains `click',
  266.      but the event symbol name itself does not contain `click'.
  267.  
  268.  - Function: event-basic-type EVENT
  269.      This function returns the key or mouse button that EVENT
  270.      describes, with all modifiers removed.  For example:
  271.  
  272.           (event-basic-type ?a)
  273.                => 97
  274.           (event-basic-type ?A)
  275.                => 97
  276.           (event-basic-type ?\C-a)
  277.                => 97
  278.           (event-basic-type ?\C-\S-a)
  279.                => 97
  280.           (event-basic-type 'f5)
  281.                => f5
  282.           (event-basic-type 's-f5)
  283.                => f5
  284.           (event-basic-type 'M-S-f5)
  285.                => f5
  286.           (event-basic-type 'down-mouse-1)
  287.                => mouse-1
  288.  
  289.  - Function: mouse-movement-p OBJECT
  290.      This function returns non-`nil' if OBJECT is a mouse movement
  291.      event.
  292.  
  293. 
  294. File: elisp,  Node: Accessing Events,  Next: Strings of Events,  Prev: Classifying Events,  Up: Input Events
  295.  
  296. Accessing Events
  297. ----------------
  298.  
  299.    This section describes convenient functions for accessing the data in
  300. an event which is a list.
  301.  
  302.    The following functions return the starting or ending position of a
  303. mouse-button event.  The position is a list of this form:
  304.  
  305.      (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
  306.  
  307.  - Function: event-start EVENT
  308.      This returns the starting position of EVENT.
  309.  
  310.      If EVENT is a click or button-down event, this returns the
  311.      location of the event.  If EVENT is a drag event, this returns the
  312.      drag's starting position.
  313.  
  314.  - Function: event-end EVENT
  315.      This returns the ending position of EVENT.
  316.  
  317.      If EVENT is a drag event, this returns the position where the user
  318.      released the mouse button.  If EVENT is a click or button-down
  319.      event, the value is actually the starting position, which is the
  320.      only position such events have.
  321.  
  322.    These four functions take a position-list as described above, and
  323. return various parts of it.
  324.  
  325.  - Function: posn-window POSITION
  326.      Return the window that POSITION is in.
  327.  
  328.  - Function: posn-point POSITION
  329.      Return the buffer location in POSITION.
  330.  
  331.  - Function: posn-col-row POSITION
  332.      Return the row and column in POSITION, as a list `(COL . ROW)'.
  333.  
  334.  - Function: posn-timestamp POSITION
  335.      Return the timestamp of POSITION.
  336.  
  337.  - Function: scroll-bar-scale RATIO TOTAL
  338.      This function multiples (in effect) RATIO by TOTAL, rounding the
  339.      result to an integer.  RATIO is not a number, but rather  a pair
  340.      `(NUM . DENOM)'.
  341.  
  342.      This is handy for scaling a position on a scroll bar into a buffer
  343.      position.  Here's how to do that:
  344.  
  345.           (+ (point-min)
  346.              (scroll-bar-scale
  347.                 (posn-col-row (event-start event))
  348.                 (- (point-max) (point-min))))
  349.  
  350. 
  351. File: elisp,  Node: Strings of Events,  Prev: Accessing Events,  Up: Input Events
  352.  
  353. Putting Keyboard Events in Strings
  354. ----------------------------------
  355.  
  356.    In most of the places where strings are used, we conceptualize the
  357. string as containing text characters--the same kind of characters found
  358. in buffers or files.  Occasionally Lisp programs use strings which
  359. conceptually contain keyboard characters; for example, they may be key
  360. sequences or keyboard macro definitions.  There are special rules for
  361. how to put keyboard characters into a string, because they are not
  362. limited to the range of 0 to 255 as text characters are.
  363.  
  364.    A keyboard character typed using the META key is called a "meta
  365. character".  The numeric code for such an event includes the 2**23 bit;
  366. it does not even come close to fitting in a string.  However, earlier
  367. Emacs versions used a different representation for these characters,
  368. which gave them codes in the range of 128 to 255.  That did fit in a
  369. string, and many Lisp programs contain string constants that use `\M-'
  370. to express meta characters, especially as the argument to `define-key'
  371. and similar functions.
  372.  
  373.    We provide backward compatibility to run those programs with special
  374. rules for how to put a keyboard character event in a string.  Here are
  375. the rules:
  376.  
  377.    * If the keyboard event value is in the range of 0 to 127, it can go
  378.      in the string unchanged.
  379.  
  380.    * The meta variants of those events, with codes in the range of
  381.      2**23 to 2**23+127, can also go in the string, but you must change
  382.      their numeric values.  You must set the 2**7 bit instead of the
  383.      2**23 bit, resulting in a value between 128 and 255.
  384.  
  385.    * Other keyboard character events cannot fit in a string.  This
  386.      includes keyboard events in the range of 128 to 255.
  387.  
  388.    Functions such as `read-key-sequence' that can construct strings
  389. containing events follow these rules.
  390.  
  391.    When you use the read syntax `\M-' in a string, it produces a code
  392. in the range of 128 to 255--the same code that you get if you modify
  393. the corresponding keyboard event to put it in the string.  Thus, meta
  394. events in strings work consistently regardless of how they get into the
  395. strings.
  396.  
  397.    New programs can avoid dealing with these rules by using vectors
  398. instead of strings for key sequences when there is any possibility that
  399. these issues might arise.
  400.  
  401.    The reason we changed the representation of meta characters as
  402. keyboard events is to make room for basic character codes beyond 127,
  403. and support meta variants of such larger character codes.
  404.  
  405. 
  406. File: elisp,  Node: Reading Input,  Next: Waiting,  Prev: Input Events,  Up: Command Loop
  407.  
  408. Reading Input
  409. =============
  410.  
  411.    The editor command loop reads keyboard input using the function
  412. `read-key-sequence', which uses `read-event'.  These and other
  413. functions for keyboard input are also available for use in Lisp
  414. programs.  See also `momentary-string-display' in *Note Temporary
  415. Displays::, and `sit-for' in *Note Waiting::.  *Note Terminal Input::,
  416. for functions and variables for controlling terminal input modes and
  417. debugging terminal input.
  418.  
  419.    For higher-level input facilities, see *Note Minibuffers::.
  420.  
  421. * Menu:
  422.  
  423. * Key Sequence Input::        How to read one key sequence.
  424. * Reading One Event::        How to read just one event.
  425. * Quoted Character Input::    Asking the user to specify a character.
  426. * Peeking and Discarding::    How to reread or throw away input events.
  427.  
  428. 
  429. File: elisp,  Node: Key Sequence Input,  Next: Reading One Event,  Up: Reading Input
  430.  
  431. Key Sequence Input
  432. ------------------
  433.  
  434.    The command loop reads input a key sequence at a time, by calling
  435. `read-key-sequence'.  Lisp programs can also call this function; for
  436. example, `describe-key' uses it to read the key to describe.
  437.  
  438.  - Function: read-key-sequence PROMPT
  439.      This function reads a key sequence and returns it as a string or
  440.      vector.  It keeps reading events until it has accumulated a full
  441.      key sequence; that is, enough to specify a non-prefix command
  442.      using the currently active keymaps.
  443.  
  444.      If the events are all characters and all can fit in a string, then
  445.      `read-key-sequence' returns a string (*note Strings of Events::.).
  446.      Otherwise, it returns a vector, since a vector can hold all kinds
  447.      of events--characters, symbols, and lists.  The elements of the
  448.      string or vector are the events in the key sequence.
  449.  
  450.      Quitting is suppressed inside `read-key-sequence'.  In other words,
  451.      a `C-g' typed while reading with this function is treated like any
  452.      other character, and does not set `quit-flag'.  *Note Quitting::.
  453.  
  454.      The argument PROMPT is either a string to be displayed in the echo
  455.      area as a prompt, or `nil', meaning not to display a prompt.
  456.  
  457.      In the example below, the prompt `?' is displayed in the echo area,
  458.      and the user types `C-x C-f'.
  459.  
  460.           (read-key-sequence "?")
  461.           
  462.           ---------- Echo Area ----------
  463.           ?`C-x C-f'
  464.           ---------- Echo Area ----------
  465.           
  466.                => "^X^F"
  467.  
  468.  - Variable: num-input-keys
  469.      This variable's value is the number of key sequences processed so
  470.      far in this Emacs session.  This includes key sequences read from
  471.      the terminal and key sequences read from keyboard macros being
  472.      executed.
  473.  
  474.    If an input character is an upper case letter and has no key binding,
  475. but the lower case equivalent has one, then `read-key-sequence'
  476. converts the character to lower case.  Note that `lookup-key' does not
  477. perform case conversion in this way.
  478.  
  479.    The function `read-key-sequence' also transforms some mouse events.
  480. It converts unbound drag events into click events, and discards unbound
  481. button-down events entirely.  It also reshuffles focus events so that
  482. they never appear in a key sequence with any other events.
  483.  
  484.    When mouse events occur in special parts of a window, such as a mode
  485. line or a scroll bar, the event itself shows nothing special--only the
  486. symbol that would normally represent that mouse button and modifier
  487. keys.  The information about the screen region is kept elsewhere in the
  488. event--in the coordinates.  But `read-key-sequence' translates this
  489. information into imaginary prefix keys, all of which are symbols:
  490. `mode-line', `vertical-line', `horizontal-scroll-bar' and
  491. `vertical-scroll-bar'.
  492.  
  493.    For example, if you call `read-key-sequence' and then click the
  494. mouse on the window's mode line, this is what happens:
  495.  
  496.      (read-key-sequence "Click on the mode line: ")
  497.           => [mode-line
  498.                (mouse-1
  499.                 (#<window 6 on NEWS> mode-line
  500.                  (40 . 63) 5959987))]
  501.  
  502.    You can define meanings for mouse clicks in special window regions by
  503. defining key sequences using these imaginary prefix keys.
  504.  
  505. 
  506. File: elisp,  Node: Reading One Event,  Next: Quoted Character Input,  Prev: Key Sequence Input,  Up: Reading Input
  507.  
  508. Reading One Event
  509. -----------------
  510.  
  511.    The lowest level functions for command input are those which read a
  512. single event.
  513.  
  514.  - Function: read-event
  515.      This function reads and returns the next event of command input,
  516.      waiting if necessary until an event is available.  Events can come
  517.      directly from the user or from a keyboard macro.
  518.  
  519.      The function `read-event' does not display any message to indicate
  520.      it is waiting for input; use `message' first, if you wish to
  521.      display one.  If you have not displayed a message, `read-event'
  522.      does "prompting": it displays descriptions of the events that led
  523.      to or were read by the current command.  *Note The Echo Area::.
  524.  
  525.      If `cursor-in-echo-area' is non-`nil', then `read-event' moves the
  526.      cursor temporarily to the echo area, to the end of any message
  527.      displayed there.  Otherwise `read-event' does not move the cursor.
  528.  
  529.    Here is what happens if you call `read-event' and then press the
  530. right-arrow function key:
  531.  
  532.      (read-event)
  533.           => right
  534.  
  535.  - Function: read-char
  536.      This function reads and returns a character of command input.  It
  537.      discards any events that are not characters until it gets a
  538.      character.
  539.  
  540.      In the first example, the user types `1' (which is ASCII code 49).
  541.      The second example shows a keyboard macro definition that calls
  542.      `read-char' from the minibuffer.  `read-char' reads the keyboard
  543.      macro's very next character, which is `1'.  The value of this
  544.      function is displayed in the echo area by the command
  545.      `eval-expression'.
  546.  
  547.           (read-char)
  548.                => 49
  549.           
  550.           (symbol-function 'foo)
  551.                => "^[^[(read-char)^M1"
  552.           (execute-kbd-macro foo)
  553.                -| 49
  554.                => nil
  555.  
  556. 
  557. File: elisp,  Node: Quoted Character Input,  Next: Peeking and Discarding,  Prev: Reading One Event,  Up: Reading Input
  558.  
  559. Quoted Character Input
  560. ----------------------
  561.  
  562.    You can use the function `read-quoted-char' when you want the user
  563. to specify a character, and allow the user to specify a control or meta
  564. character conveniently with quoting or as an octal character code.  The
  565. command `quoted-insert' calls this function.
  566.  
  567.  - Function: read-quoted-char &optional PROMPT
  568.      This function is like `read-char', except that if the first
  569.      character read is an octal digit (0-7), it reads up to two more
  570.      octal digits (but stopping if a non-octal digit is found) and
  571.      returns the character represented by those digits as an octal
  572.      number.
  573.  
  574.      Quitting is suppressed when the first character is read, so that
  575.      the user can enter a `C-g'.  *Note Quitting::.
  576.  
  577.      If PROMPT is supplied, it specifies a string for prompting the
  578.      user.  The prompt string is always printed in the echo area and
  579.      followed by a single `-'.
  580.  
  581.      In the following example, the user types in the octal number 177
  582.      (which is 127 in decimal).
  583.  
  584.           (read-quoted-char "What character")
  585.           
  586.           ---------- Echo Area ----------
  587.           What character-`177'
  588.           ---------- Echo Area ----------
  589.           
  590.                => 127
  591.  
  592. 
  593. File: elisp,  Node: Peeking and Discarding,  Prev: Quoted Character Input,  Up: Reading Input
  594.  
  595. Peeking and Discarding
  596. ----------------------
  597.  
  598.  - Variable: unread-command-events
  599.      This variable holds a list of events waiting to be read as command
  600.      input.  The events are used in the order they appear in the list.
  601.  
  602.      The variable is used because in some cases a function reads a
  603.      event and then decides not to use it.  Storing the event in this
  604.      variable causes it to be processed normally by the command loop or
  605.      when the functions to read command input are called.
  606.  
  607.      For example, the function that implements numeric prefix arguments
  608.      reads any number of digits.  When it finds a non-digit event, it
  609.      must unread the event so that it can be read normally by the
  610.      command loop.  Likewise, incremental search uses this feature to
  611.      unread events it does not recognize.
  612.  
  613.  - Variable: unread-command-char
  614.      This variable holds a character to be read as command input.  A
  615.      value of -1 means "empty".
  616.  
  617.      This variable is pretty much obsolete now that you can use
  618.      `unread-command-events' instead; it exists only to support programs
  619.      written for Emacs versions 18 and earlier.
  620.  
  621.  - Function: listify-key-sequence KEY
  622.      This function converts the string or vector KEY to a list of
  623.      events which you can put in `unread-command-events'.  Converting a
  624.      vector is simple, but converting a string is tricky because of the
  625.      special representation used for meta characters in a string (*note
  626.      Strings of Events::.).
  627.  
  628.  - Function: input-pending-p
  629.      This function determines whether any command input is currently
  630.      available to be read.  It returns immediately, with value `t' if
  631.      there is input, `nil' otherwise.  On rare occasions it may return
  632.      `t' when no input is available.
  633.  
  634.  - Variable: last-input-event
  635.  - Variable: last-input-char
  636.      This variable records the last terminal input event read, whether
  637.      as part of a command or explicitly by a Lisp program.
  638.  
  639.      In the example below, a character is read (the character `1',
  640.      ASCII code 49).  It becomes the value of `last-input-char', while
  641.      `C-e' (from the `C-x C-e' command used to evaluate this
  642.      expression) remains the value of `last-command-char'.
  643.  
  644.           (progn (print (read-char))
  645.                  (print last-command-char)
  646.                  last-input-char)
  647.                -| 49
  648.                -| 5
  649.                => 49
  650.  
  651.      The alias `last-input-char' exists for compatibility with Emacs
  652.      version 18.
  653.  
  654.  - Function: discard-input
  655.      This function discards the contents of the terminal input buffer
  656.      and cancels any keyboard macro that might be in the process of
  657.      definition.  It returns `nil'.
  658.  
  659.      In the following example, the user may type a number of characters
  660.      right after starting the evaluation of the form.  After the
  661.      `sleep-for' finishes sleeping, any characters that have been typed
  662.      are discarded.
  663.  
  664.           (progn (sleep-for 2)
  665.             (discard-input))
  666.                => nil
  667.  
  668. 
  669. File: elisp,  Node: Waiting,  Next: Quitting,  Prev: Reading Input,  Up: Command Loop
  670.  
  671. Waiting for Elapsed Time or Input
  672. =================================
  673.  
  674.    The waiting commands are designed to make Emacs wait for a certain
  675. amount of time to pass or until there is input.  For example, you may
  676. wish to pause in the middle of a computation to allow the user time to
  677. view the display.  `sit-for' pauses and updates the screen, and returns
  678. immediately if input comes in, while `sleep-for' pauses without
  679. updating the screen.
  680.  
  681.  - Function: sit-for SECONDS &optional MILLISEC NODISP
  682.      This function performs redisplay (provided there is no pending
  683.      input from the user), then waits SECONDS seconds, or until input is
  684.      available.  The result is `t' if `sit-for' waited the full time
  685.      with no input arriving (see `input-pending-p' in *Note Peeking and
  686.      Discarding::).  Otherwise, the value is `nil'.
  687.  
  688.      The optional argument MILLISEC specifies an additional waiting
  689.      period measured in milliseconds.  This adds to the period
  690.      specified by SECONDS.  Not all operating systems support waiting
  691.      periods other than multiples of a second; on those that do not,
  692.      you get an error if you specify nonzero MILLISEC.
  693.  
  694.      Redisplay is always preempted if input arrives, and does not
  695.      happen at all if input is available before it starts.  Thus, there
  696.      is no way to force screen updating if there is pending input;
  697.      however, if there is no input pending, you can force an update
  698.      with no delay by using `(sit-for 0)'.
  699.  
  700.      If NODISP is non-`nil', then `sit-for' does not redisplay, but it
  701.      still returns as soon as input is available (or when the timeout
  702.      elapses).
  703.  
  704.      The usual purpose of `sit-for' is to give the user time to read
  705.      text that you display.
  706.  
  707.  - Function: sleep-for SECONDS &optional MILLISEC
  708.      This function simply pauses for SECONDS seconds without updating
  709.      the display.  It pays no attention to available input.  It returns
  710.      `nil'.
  711.  
  712.      The optional argument MILLISEC specifies an additional waiting
  713.      period measured in milliseconds.  This adds to the period
  714.      specified by SECONDS.  Not all operating systems support waiting
  715.      periods other than multiples of a second; on those that do not,
  716.      you get an error if you specify nonzero MILLISEC.
  717.  
  718.      Use `sleep-for' when you wish to guarantee a delay.
  719.  
  720.    *Note Time of Day::, for functions to get the current time.
  721.  
  722. 
  723. File: elisp,  Node: Quitting,  Next: Prefix Command Arguments,  Prev: Waiting,  Up: Command Loop
  724.  
  725. Quitting
  726. ========
  727.  
  728.    Typing `C-g' while the command loop has run a Lisp function causes
  729. Emacs to "quit" whatever it is doing.  This means that control returns
  730. to the innermost active command loop.
  731.  
  732.    Typing `C-g' while the command loop is waiting for keyboard input
  733. does not cause a quit; it acts as an ordinary input character.  In the
  734. simplest case, you cannot tell the difference, because `C-g' normally
  735. runs the command `keyboard-quit', whose effect is to quit.  However,
  736. when `C-g' follows a prefix key, the result is an undefined key.  The
  737. effect is to cancel the prefix key as well as any prefix argument.
  738.  
  739.    In the minibuffer, `C-g' has a different definition: it aborts out
  740. of the minibuffer.  This means, in effect, that it exits the minibuffer
  741. and then quits.  (Simply quitting would return to the command loop
  742. *within* the minibuffer.)  The reason why `C-g' does not quit directly
  743. when the command reader is reading input is so that its meaning can be
  744. redefined in the minibuffer in this way.  `C-g' following a prefix key
  745. is not redefined in the minibuffer, and it has its normal effect of
  746. canceling the prefix key and prefix argument.  This too would not be
  747. possible if `C-g' quit directly.
  748.  
  749.    `C-g' causes a quit by setting the variable `quit-flag' to a
  750. non-`nil' value.  Emacs checks this variable at appropriate times and
  751. quits if it is not `nil'.  Setting `quit-flag' non-`nil' in any way
  752. thus causes a quit.
  753.  
  754.    At the level of C code, quits cannot happen just anywhere; only at
  755. the special places which check `quit-flag'.  The reason for this is
  756. that quitting at other places might leave an inconsistency in Emacs's
  757. internal state.  Because quitting is delayed until a safe place,
  758. quitting cannot make Emacs crash.
  759.  
  760.    Certain functions such as `read-key-sequence' or `read-quoted-char'
  761. prevent quitting entirely even though they wait for input.  Instead of
  762. quitting, `C-g' serves as the requested input.  In the case of
  763. `read-key-sequence', this serves to bring about the special behavior of
  764. `C-g' in the command loop.  In the case of `read-quoted-char', this is
  765. so that `C-q' can be used to quote a `C-g'.
  766.  
  767.    You can prevent quitting for a portion of a Lisp function by binding
  768. the variable `inhibit-quit' to a non-`nil' value.  Then, although `C-g'
  769. still sets `quit-flag' to `t' as usual, the usual result of this--a
  770. quit--is prevented.  Eventually, `inhibit-quit' will become `nil'
  771. again, such as when its binding is unwound at the end of a `let' form.
  772. At that time, if `quit-flag' is still non-`nil', the requested quit
  773. happens immediately.  This behavior is ideal for a "critical section",
  774. where you wish to make sure that quitting does not happen within that
  775. part of the program.
  776.  
  777.    In some functions (such as `read-quoted-char'), `C-g' is handled in
  778. a special way which does not involve quitting.  This is done by reading
  779. the input with `inhibit-quit' bound to `t' and setting `quit-flag' to
  780. `nil' before `inhibit-quit' becomes `nil' again.  This excerpt from the
  781. definition of `read-quoted-char' shows how this is done; it also shows
  782. that normal quitting is permitted after the first character of input.
  783.  
  784.      (defun read-quoted-char (&optional prompt)
  785.        "...DOCUMENTATION..."
  786.        (let ((count 0) (code 0) char)
  787.          (while (< count 3)
  788.            (let ((inhibit-quit (zerop count))
  789.                  (help-form nil))
  790.              (and prompt (message "%s-" prompt))
  791.              (setq char (read-char))
  792.              (if inhibit-quit (setq quit-flag nil)))
  793.            ...)
  794.          (logand 255 code)))
  795.  
  796.  - Variable: quit-flag
  797.      If this variable is non-`nil', then Emacs quits immediately,
  798.      unless `inhibit-quit' is non-`nil'.  Typing `C-g' sets `quit-flag'
  799.      non-`nil', regardless of `inhibit-quit'.
  800.  
  801.  - Variable: inhibit-quit
  802.      This variable determines whether Emacs should quit when `quit-flag'
  803.      is set to a value other than `nil'.  If `inhibit-quit' is
  804.      non-`nil', then `quit-flag' has no special effect.
  805.  
  806.  - Command: keyboard-quit
  807.      This function signals the `quit' condition with `(signal 'quit
  808.      nil)'.  This is the same thing that quitting does.  (See `signal'
  809.      in *Note Errors::.)
  810.  
  811.    You can specify a character other than `C-g' to use for quitting.
  812. See the function `set-input-mode' in *Note Terminal Input::.
  813.  
  814. 
  815. File: elisp,  Node: Prefix Command Arguments,  Next: Recursive Editing,  Prev: Quitting,  Up: Command Loop
  816.  
  817. Prefix Command Arguments
  818. ========================
  819.  
  820.    Most Emacs commands can use a "prefix argument", a number specified
  821. before the command itself.  (Don't confuse prefix arguments with prefix
  822. keys.)  The prefix argument is represented by a value that is always
  823. available (though it may be `nil', meaning there is no prefix
  824. argument).  Each command may use the prefix argument or ignore it.
  825.  
  826.    There are two representations of the prefix argument: "raw" and
  827. "numeric".  The editor command loop uses the raw representation
  828. internally, and so do the Lisp variables that store the information, but
  829. commands can request either representation.
  830.  
  831.    Here are the possible values of a raw prefix argument:
  832.  
  833.    * `nil', meaning there is no prefix argument.  Its numeric value is
  834.      1, but numerous commands make a distinction between `nil' and the
  835.      integer 1.
  836.  
  837.    * An integer, which stands for itself.
  838.  
  839.    * A list of one element, which is an integer.  This form of prefix
  840.      argument results from one or a succession of `C-u''s with no
  841.      digits.  The numeric value is the integer in the list, but some
  842.      commands make a distinction between such a list and an integer
  843.      alone.
  844.  
  845.    * The symbol `-'.  This indicates that `M--' or `C-u -' was typed,
  846.      without following digits.  The equivalent numeric value is -1, but
  847.      some commands make a distinction between the integer -1 and the
  848.      symbol `-'.
  849.  
  850.    The various possibilities may be illustrated by calling the following
  851. function with various prefixes:
  852.  
  853.      (defun display-prefix (arg)
  854.        "Display the value of the raw prefix arg."
  855.        (interactive "P")
  856.        (message "%s" arg))
  857.  
  858. Here are the results of calling `print-prefix' with various raw prefix
  859. arguments:
  860.  
  861.              M-x print-prefix  -| nil
  862.      
  863.      C-u     M-x print-prefix  -| (4)
  864.      
  865.      C-u C-u M-x print-prefix  -| (16)
  866.      
  867.      C-u 3   M-x print-prefix  -| 3
  868.      
  869.      M-3     M-x print-prefix  -| 3      ; (Same as `C-u 3'.)
  870.      
  871.      C-u -   M-x print-prefix  -| -
  872.      
  873.      M- -    M-x print-prefix  -| -      ; (Same as `C-u -'.)
  874.      
  875.      C-u -7  M-x print-prefix  -| -7
  876.      
  877.      M- -7   M-x print-prefix  -| -7     ; (Same as `C-u -7'.)
  878.  
  879.    Emacs uses two variables to store the prefix argument: `prefix-arg'
  880. and `current-prefix-arg'.  Commands such as `universal-argument' that
  881. set up prefix arguments for other commands store them in `prefix-arg'.
  882. In contrast, `current-prefix-arg' conveys the prefix argument to the
  883. current command, so setting it has no effect on the prefix arguments
  884. for future commands.
  885.  
  886.    Normally, commands specify which representation to use for the prefix
  887. argument, either numeric or raw, in the `interactive' declaration.
  888. (*Note Interactive Call::.)  Alternatively, functions may look at the
  889. value of the prefix argument directly in the variable
  890. `current-prefix-arg', but this is less clean.
  891.  
  892.    Do not call the functions `universal-argument', `digit-argument', or
  893. `negative-argument' unless you intend to let the user enter the prefix
  894. argument for the *next* command.
  895.  
  896.  - Command: universal-argument
  897.      This command reads input and specifies a prefix argument for the
  898.      following command.  Don't call this command yourself unless you
  899.      know what you are doing.
  900.  
  901.  - Command: digit-argument ARG
  902.      This command adds to the prefix argument for the following
  903.      command.  The argument ARG is the raw prefix argument as it was
  904.      before this command; it is used to compute the updated prefix
  905.      argument.  Don't call this command yourself unless you know what
  906.      you are doing.
  907.  
  908.  - Command: negative-argument ARG
  909.      This command adds to the numeric argument for the next command.
  910.      The argument ARG is the raw prefix argument as it was before this
  911.      command; its value is negated to form the new prefix argument.
  912.      Don't call this command yourself unless you know what you are
  913.      doing.
  914.  
  915.  - Function: prefix-numeric-value ARG
  916.      This function returns the numeric meaning of a valid raw prefix
  917.      argument value, ARG.  The argument may be a symbol, a number, or a
  918.      list.  If it is `nil', the value 1 is returned; if it is any other
  919.      symbol, the value -1 is returned.  If it is a number, that number
  920.      is returned; if it is a list, the CAR of that list (which should
  921.      be a number) is returned.
  922.  
  923.  - Variable: current-prefix-arg
  924.      This variable is the value of the raw prefix argument for the
  925.      *current* command.  Commands may examine it directly, but the usual
  926.      way to access it is with `(interactive "P")'.
  927.  
  928.  - Variable: prefix-arg
  929.      The value of this variable is the raw prefix argument for the
  930.      *next* editing command.  Commands that specify prefix arguments for
  931.      the following command work by setting this variable.
  932.  
  933. 
  934. File: elisp,  Node: Recursive Editing,  Next: Disabling Commands,  Prev: Prefix Command Arguments,  Up: Command Loop
  935.  
  936. Recursive Editing
  937. =================
  938.  
  939.    The Emacs command loop is entered automatically when Emacs starts up.
  940. This top-level invocation of the command loop is never exited until the
  941. Emacs is killed.  Lisp programs can also invoke the command loop.  Since
  942. this makes more than one activation of the command loop, we call it
  943. "recursive editing".  A recursive editing level has the effect of
  944. suspending whatever command invoked it and permitting the user to do
  945. arbitrary editing before resuming that command.
  946.  
  947.    The commands available during recursive editing are the same ones
  948. available in the top-level editing loop and defined in the keymaps.
  949. Only a few special commands exit the recursive editing level; the others
  950. return to the recursive editing level when finished.  (The special
  951. commands for exiting are always available, but do nothing when recursive
  952. editing is not in progress.)
  953.  
  954.    All command loops, including recursive ones, set up all-purpose error
  955. handlers so that an error in a command run from the command loop will
  956. not exit the loop.
  957.  
  958.    Minibuffer input is a special kind of recursive editing.  It has a
  959. few special wrinkles, such as enabling display of the minibuffer and the
  960. minibuffer window, but fewer than you might suppose.  Certain keys
  961. behave differently in the minibuffer, but that is only because of the
  962. minibuffer's local map; if you switch windows, you get the usual Emacs
  963. commands.
  964.  
  965.    To invoke a recursive editing level, call the function
  966. `recursive-edit'.  This function contains the command loop; it also
  967. contains a call to `catch' with tag `exit', which makes it possible to
  968. exit the recursive editing level by throwing to `exit' (*note Catch and
  969. Throw::.).  If you throw a value other than `t', then `recursive-edit'
  970. returns normally to the function that called it.  The command `C-M-c'
  971. (`exit-recursive-edit') does this.  Throwing a `t' value causes
  972. `recursive-edit' to quit, so that control returns to the command loop
  973. one level up.  This is called "aborting", and is done by `C-]'
  974. (`abort-recursive-edit').
  975.  
  976.    Most applications should not use recursive editing, except as part of
  977. using the minibuffer.  Usually it is more convenient for the user if you
  978. change the major mode of the current buffer temporarily to a special
  979. major mode, which has a command to go back to the previous mode.  (This
  980. technique is used by the `w' command in Rmail.)  Or, if you wish to
  981. give the user different text to edit "recursively", create and select a
  982. new buffer in a special mode.  In this mode, define a command to
  983. complete the processing and go back to the previous buffer.  (The `m'
  984. command in Rmail does this.)
  985.  
  986.    Recursive edits are useful in debugging.  You can insert a call to
  987. `debug' into a function definition as a sort of breakpoint, so that you
  988. can look around when the function gets there.  `debug' invokes a
  989. recursive edit but also provides the other features of the debugger.
  990.  
  991.    Recursive editing levels are also used when you type `C-r' in
  992. `query-replace' or use `C-x q' (`kbd-macro-query').
  993.  
  994.  - Function: recursive-edit
  995.      This function invokes the editor command loop.  It is called
  996.      automatically by the initialization of Emacs, to let the user begin
  997.      editing.  When called from a Lisp program, it enters a recursive
  998.      editing level.
  999.  
  1000.      In the following example, the function `simple-rec' first advances
  1001.      point one word, then enters a recursive edit, printing out a
  1002.      message in the echo area.  The user can then do any editing
  1003.      desired, and then type `C-M-c' to exit and continue executing
  1004.      `simple-rec'.
  1005.  
  1006.           (defun simple-rec ()
  1007.             (forward-word 1)
  1008.             (message "Recursive edit in progress.")
  1009.             (recursive-edit)
  1010.             (forward-word 1))
  1011.                => simple-rec
  1012.           (simple-rec)
  1013.                => nil
  1014.  
  1015.  - Command: exit-recursive-edit
  1016.      This function exits from the innermost recursive edit (including
  1017.      minibuffer input).  Its definition is effectively `(throw 'exit
  1018.      nil)'.
  1019.  
  1020.  - Command: abort-recursive-edit
  1021.      This function aborts the command that requested the innermost
  1022.      recursive edit (including minibuffer input), by signaling `quit'
  1023.      after exiting the recursive edit.  Its definition is effectively
  1024.      `(throw 'exit t)'.  *Note Quitting::.
  1025.  
  1026.  - Command: top-level
  1027.      This function exits all recursive editing levels; it does not
  1028.      return a value, as it jumps completely out of any computation
  1029.      directly back to the main command loop.
  1030.  
  1031.  - Function: recursion-depth
  1032.      This function returns the current depth of recursive edits.  When
  1033.      no recursive edit is active, it returns 0.
  1034.  
  1035. 
  1036. File: elisp,  Node: Disabling Commands,  Next: Command History,  Prev: Recursive Editing,  Up: Command Loop
  1037.  
  1038. Disabling Commands
  1039. ==================
  1040.  
  1041.    "Disabling a command" marks the command as requiring user
  1042. confirmation before it can be executed.  Disabling is used for commands
  1043. which might be confusing to beginning users, to prevent them from using
  1044. the commands by accident.
  1045.  
  1046.    The low-level mechanism for disabling a command is to put a
  1047. non-`nil' `disabled' property on the Lisp symbol for the command.
  1048. These properties are normally set up by the user's `.emacs' file with
  1049. Lisp expressions such as this:
  1050.  
  1051.      (put 'upcase-region 'disabled t)
  1052.  
  1053. For a few commands, these properties are present by default and may be
  1054. removed by the `.emacs' file.
  1055.  
  1056.    If the value of the `disabled' property is a string, that string is
  1057. included in the message printed when the command is used:
  1058.  
  1059.      (put 'delete-region 'disabled
  1060.           "Text deleted this way cannot be yanked back!\n")
  1061.  
  1062.    *Note Disabling: (emacs)Disabling, for the details on what happens
  1063. when a disabled command is invoked interactively.  Disabling a command
  1064. has no effect on calling it as a function from Lisp programs.
  1065.  
  1066.  - Command: enable-command COMMAND
  1067.      Allow COMMAND to be executed without special confirmation from now
  1068.      on.  The user's `.emacs' file is optionally altered so that this
  1069.      will apply to future sessions.
  1070.  
  1071.  - Command: disable-command COMMAND
  1072.      Require special confirmation to execute COMMAND from now on.  The
  1073.      user's `.emacs' file is optionally altered so that this will apply
  1074.      to future sessions.
  1075.  
  1076.  - Variable: disabled-command-hook
  1077.      This variable is a normal hook that is run instead of a disabled
  1078.      command, when the user runs the disabled command interactively.
  1079.      The hook functions can use `this-command-keys' to determine what
  1080.      the user typed to run the command, and thus find the command
  1081.      itself.
  1082.  
  1083.      By default, `disabled-command-hook' contains a function that asks
  1084.      the user whether to proceed.
  1085.  
  1086. 
  1087. File: elisp,  Node: Command History,  Next: Keyboard Macros,  Prev: Disabling Commands,  Up: Command Loop
  1088.  
  1089. Command History
  1090. ===============
  1091.  
  1092.    The command loop keeps a history of the complex commands that have
  1093. been executed, to make it convenient to repeat these commands.  A
  1094. "complex command" is one for which the interactive argument reading
  1095. uses the minibuffer.  This includes any `M-x' command, any `M-ESC'
  1096. command, and any command whose `interactive' specification reads an
  1097. argument from the minibuffer.  Explicit use of the minibuffer during
  1098. the execution of the command itself does not cause the command to be
  1099. considered complex.
  1100.  
  1101.  - Variable: command-history
  1102.      This variable's value is a list of recent complex commands, each
  1103.      represented as a form to evaluate.  It continues to accumulate all
  1104.      complex commands for the duration of the editing session, but all
  1105.      but the first (most recent) thirty elements are deleted when a
  1106.      garbage collection takes place (*note Garbage Collection::.).
  1107.  
  1108.           command-history
  1109.           => ((switch-to-buffer "chistory.texi")
  1110.               (describe-key "^X^[")
  1111.               (visit-tags-table "~/emacs/src/")
  1112.               (find-tag "repeat-complex-command"))
  1113.  
  1114.    This history list is actually a special case of minibuffer history
  1115. (*note Minibuffer History::.), with one special twist: the elements are
  1116. expressions rather than strings.
  1117.  
  1118.    There are a number of commands devoted to the editing and recall of
  1119. previous commands.  The commands `repeat-complex-command', and
  1120. `list-command-history' are described in the user manual (*note
  1121. Repetition: (emacs)Repetition.).  Within the minibuffer, the history
  1122. commands used are the same ones available in any minibuffer.
  1123.  
  1124. 
  1125. File: elisp,  Node: Keyboard Macros,  Prev: Command History,  Up: Command Loop
  1126.  
  1127. Keyboard Macros
  1128. ===============
  1129.  
  1130.    A "keyboard macro" is a canned sequence of input events that can be
  1131. considered a command and made the definition of a key.  Don't confuse
  1132. keyboard macros with Lisp macros (*note Macros::.).
  1133.  
  1134.  - Function: execute-kbd-macro MACRO &optional COUNT
  1135.      This function executes MACRO as a sequence of events.  If MACRO is
  1136.      a string or vector, then the events in it are executed exactly as
  1137.      if they had been input by the user.  The sequence is *not*
  1138.      expected to be a single key sequence; normally a keyboard macro
  1139.      definition consists of several key sequences concatenated.
  1140.  
  1141.      If MACRO is a symbol, then its function definition is used in
  1142.      place of MACRO.  If that is another symbol, this process repeats.
  1143.      Eventually the result should be a string or vector.  If the result
  1144.      is not a symbol, string, or vector, an error is signaled.
  1145.  
  1146.      The argument COUNT is a repeat count; MACRO is executed that many
  1147.      times.  If COUNT is omitted or `nil', MACRO is executed once.  If
  1148.      it is 0, MACRO is executed over and over until it encounters an
  1149.      error or a failing search.
  1150.  
  1151.  - Variable: last-kbd-macro
  1152.      This variable is the definition of the most recently defined
  1153.      keyboard macro.  Its value is a string or vector, or `nil'.
  1154.  
  1155.  - Variable: executing-macro
  1156.      This variable contains the string or vector that defines the
  1157.      keyboard macro that is currently executing.  It is `nil' if no
  1158.      macro is currently executing.
  1159.  
  1160.  - Variable: defining-kbd-macro
  1161.      This variable indicates whether a keyboard macro is being defined.
  1162.      It is set to `t' by `start-kbd-macro', and `nil' by
  1163.      `end-kbd-macro'.  You can use this variable to make a command
  1164.      behave differently when run from a keyboard macro (perhaps
  1165.      indirectly by calling `interactive-p').  However, do not set this
  1166.      variable yourself.
  1167.  
  1168.    The commands are described in the user's manual (*note Keyboard
  1169. Macros: (emacs)Keyboard Macros.).
  1170.  
  1171. 
  1172. File: elisp,  Node: Keymaps,  Next: Modes,  Prev: Command Loop,  Up: Top
  1173.  
  1174. Keymaps
  1175. *******
  1176.  
  1177.    The bindings between input events and commands are recorded in data
  1178. structures called "keymaps".  Each binding in a keymap associates (or
  1179. "binds") an individual event type either with another keymap or with a
  1180. command.  When an event is bound to a keymap, that keymap is used to
  1181. look up the next character typed; this continues until a command is
  1182. found.  The whole process is called "key lookup".
  1183.  
  1184. * Menu:
  1185.  
  1186. * Keymap Terminology::            Definitions of terms pertaining to keymaps.
  1187. * Format of Keymaps::        What a keymap looks like as a Lisp object.
  1188. * Creating Keymaps::         Functions to create and copy keymaps.
  1189. * Inheritance and Keymaps::    How one keymap can inherit the bindings
  1190.                    of another keymap.
  1191. * Prefix Keys::                 Defining a key with a keymap as its definition.
  1192. * Menu Keymaps::        A keymap can define a menu.
  1193. * Active Keymaps::            Each buffer has a local keymap
  1194.                                    to override the standard (global) bindings.
  1195.                    A minor mode can also override them.
  1196. * Key Lookup::                  How extracting elements from keymaps works.
  1197. * Functions for Key Lookup::    How to request key lookup.
  1198. * Changing Key Bindings::       Redefining a key in a keymap.
  1199. * Key Binding Commands::        Interactive interfaces for redefining keys.
  1200. * Scanning Keymaps::            Looking through all keymaps, for printing help.
  1201.  
  1202.